# Importing Data
MALAYSIA<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Rubber/Rubber.xlsx",sheet = "Sheet1", range = "f1:f325")

# Checking the Imported Data
View(MALAYSIA)
# Creating Time Series Data
MALAYSIA_ts <- ts(MALAYSIA, start=c(1991,1), end=c(2017,12), frequency=12)
# Viewing and Checking the Created Time Series Data
MALAYSIA_ts
sum(is.na(MALAYSIA_ts))
library(forecast)
MALAYSIA_ts <- tsclean(MALAYSIA_ts)
MALAYSIA_ts

# Identification: Plotting the Time Series Data
plot(MALAYSIA_ts)

# Estimating the appropriate model
MALAYSIA_ts_model <- auto.arima(MALAYSIA_ts)
MALAYSIA_ts_model

# Forecasting
options(max.print=1000000)
MALAYSIA_ts_forecast <- forecast (MALAYSIA_ts_model, level=c(95), h=276)
plot(MALAYSIA_ts_forecast)
MALAYSIA_ts_forecast             

# Exporting
write.table(MALAYSIA_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Rubber/MALAYSIA_TSA.csv", sep=",")


